package cn.itrip.controller;

import cn.itrip.commons.DtoUtils;
import cn.itrip.dto.Dto;
import cn.itrip.service.ItripUserService;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author Super God Jie
 * @version 1.0  2022-04-16 08:51
 */
@RestController
@RequestMapping("/api")
public class UserController {
	@Resource
	private ItripUserService itripUserService;

	@PostMapping("/userinfo/queryuserlinkuser")
	public Dto queryuserlinkuser(HttpServletRequest request){
		if(StringUtils.hasText(request.getHeader("token"))){
			try {
				return DtoUtils.returnSuccess(itripUserService.queryUserLinkUser(request.getHeader("token")));
			} catch (Exception e) {
				return DtoUtils.returnFail("400001",e.getMessage());
			}
		}
		return DtoUtils.returnFail("400001","清先登录");
	}
}
